package com.x.reader.service;

import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import com.x.reader.dao.AppDao;
import com.x.reader.model.App;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AppService extends BaseService {

    @Autowired
    private AppDao appDao;

    public App insertApp(App app) {
        try {
            return this.insert(app);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public void updateApp(App app) {
        try {
            this.update(app);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public int deleteApp(App app) {
        try {
            return this.delete(app);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<App> selectAppList(App app) {
        try {
            return appDao.selectAppList(app);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

}
